<template>
    <div>
        <content-head>
            <div class="project-head">
                <div class="left">
                    <div class="project-round">
                        <span></span>
                    </div>
                    <div class="project-detail">
                        <p>编辑项目</p>
                        <p>创建一个令人愉快的项目</p>
                    </div>
                </div>
            </div>
        </content-head>
        <div class="project-content">
            <base-info ref="baseInfo"></base-info>
            <config ref="config"></config>

            <div class="project-footer">
                <Button type="primary">保存</Button>
                <Button @click="cancel">取消</Button>
            </div>
        </div>
    </div>
</template>

<script>
    import ContentHead from './contentHead';
    import BaseInfo from './step/baseInfo';
    import Config from './step/config';
    export default {
        data(){
            return {
                projectId: this.$route.query.id
            };
        },
        created(){
            this.initData();
        },
        components:{
            ContentHead,
            BaseInfo,
            Config,
        },
        methods:{
            cancel(){
                this.$router.push('/main/project');
            },
            initData(){
                this.$http.get('/codegen/api/v1/projects/'+this.projectId + '/show').then((response) => {
                    if (response.data.project) {
                        this.$refs['baseInfo'].initData(response.data.project);
                        this.$refs['config'].initData(response.data.project);
                    }
                });
            }
        }
    };
</script>

<style scoped lang="scss">
    .project-content {
        width: 1024px;
        margin: 18px auto;
        background-color: #fff;
        padding: 0px 16px 16px 16px;

        .project-footer{
            text-align: center;
        }
    }
</style>